package com.leo.customer.controller

import com.leo.customer.entity.pojo.WorkLabel
import com.leo.customer.entity.pojo.WorkLabelVo
import com.leo.customer.service.WorkLabelService
import com.leo.result.ResultEntity
import io.swagger.annotations.Api
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@Api("标签接口", tags = ["标签操作接口"])
@RestController
@RequestMapping("tag")
class WorkLabelController {

    @Autowired
    lateinit var workLabelService: WorkLabelService

    @PostMapping("insertLabel")
    fun addWorkLabel(workLabel: WorkLabel): MutableList<WorkLabelVo> {
        return workLabelService.addWorkLabel(workLabel)
    }

    @GetMapping("getAll")
    fun getAllLabel(): ResultEntity<MutableList<WorkLabelVo>> {
        val allLabel = workLabelService.getAllLabel()
        if (allLabel != null && allLabel.count() <= 0) {
            return ResultEntity.fail("获取失败")
        }
        return ResultEntity.success(allLabel)
    }
}
